/**
 * ReportGear(2011)
 */
package com.reportgear.report.model.script.function;

import net.abbp.core.util.StringUtils;

/**
 * 抽象函数类
 * 
 * @version 1.0 2011-4-10
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public abstract class AbstractFunction implements Function {
	private String name;

	@Override
	public String getName() {
		if (StringUtils.isEmpty(this.name)) {
			return StringUtils.firstLower(this.getClass().getSimpleName());
		} else {
			return StringUtils.firstLower(this.name);
		}
	}

	/**
	 * 设置名称
	 * 
	 * @param name
	 *            名称
	 */
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return this.getName();

	}

	@Override
	public String getDescription() {
		return this.getName();
	}

	@Override
	public int compareTo(Function o) {
		if (o == null) {
			return 1;
		}

		return this.getName().compareTo(o.getName());
	}
}
